#ifndef CVIDEOPLAYER_H
#define CVIDEOPLAYER_H

#include "Plugins/logHelper/cLoggerInterface.h"

#ifdef _WIN32
#include <windows.h>
#endif

#include <list>
#include <tuple>
#include <mutex>

namespace libcvos_vfr
{

	class cVideoPlayer : public cLoggerInterface
	{
	public:
		cVideoPlayer();
		~cVideoPlayer();

        void StartPlayVideoByChannel(int iChannelID, long winHandle, int Pox = 0, int PoxY = 0, int width = 0, int height = 0);
		int StopPlayVideoByChannel(int iChannelID);

        void stopPlayVideoByWinHandle(long winHandle);

		//bool TakeOnePictureFromVedio(int channelID, CameraIMG& camImg);
		void SetCameraIP(const char* ipAddress);

		void clear_playInfo();

	private:

        int StartPlayVideo(int iChannelID, void*& playHandle, long winHandle, int Pox = 0, int PoxY = 0, int width = 0, int height = 0);
        void StopPlayVideo( void*& playHandle);

		void* GetVideoHandleByChannel(int iChannerlID);

		void WriteFormatLog(const char* szfmt, ...);

        bool check_if_windhandle_in_use(long winHandle);
		bool check_if_channelID_in_use(int channelID);

		void close_player_by_channelid(int channelID);
        void close_player_by_windhanled(long winHandle);

        void recorde_playinfo(int channel, void* playHandle, long winHandle);

	private:

        std::list<std::tuple<int, long, void* >> m_playerList;

		unsigned char* m_pCaptureImg;

		std::string m_strIP;

		std::mutex m_lock;
	};

}
#endif
